package com.ruoyi.campus.controller;

import com.ruoyi.campus.domain.Campusdistriapply;
import com.ruoyi.campus.domain.vo.CampusdistriapplyVO;
import com.ruoyi.campus.service.ICampusdistriapplyService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 分销校区申请列表Controller
 * 
 * @author ruoyi
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/campus/campusdistriapply")
public class CampusdistriapplyController extends BaseController
{
    @Autowired
    private ICampusdistriapplyService campusdistriapplyService;

    /**
     * 查询分销校区申请列表列表
     */
//    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:list')")
    @GetMapping("/list")
    public TableDataInfo list(CampusdistriapplyVO campusdistriapplyvo)
    {
        startPage();
        List<CampusdistriapplyVO> list = campusdistriapplyService.selectCampusdistriapplyList(campusdistriapplyvo);
        return getDataTable(list);
    }

    // /**
    //  * 查询分销校区申请列表列表
    //  */
    // @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:list')")
    // @GetMapping("/list")
    // public TableDataInfo list(Campusdistriapply campusdistriapply)
    // {
    //     startPage();
    //     List<Campusdistriapply> list = campusdistriapplyService.selectCampusdistriapplyList(campusdistriapply);
    //     return getDataTable(list);
    // }


    /**
     * 导出分销校区申请列表列表
     */
    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:export')")
    @Log(title = "分销校区申请列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CampusdistriapplyVO campusdistriapplyvo)
    {
        List<CampusdistriapplyVO> list = campusdistriapplyService.selectCampusdistriapplyList(campusdistriapplyvo);
        ExcelUtil<CampusdistriapplyVO> util = new ExcelUtil<CampusdistriapplyVO>(CampusdistriapplyVO.class);
        util.exportExcel(response, list, "分销校区申请列表数据");
    }

    /**
     * 获取分销校区申请列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:query')")
    @GetMapping(value = "/{applyDistributionId}")
    public AjaxResult getInfo(@PathVariable("applyDistributionId") Integer applyDistributionId)
    {
        return success(campusdistriapplyService.selectCampusdistriapplyByApplyDistributionId(applyDistributionId));
    }

    /**
     * 新增分销校区申请列表
     */
    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:add')")
    @Log(title = "分销校区申请列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Campusdistriapply campusdistriapply)
    {
        return toAjax(campusdistriapplyService.insertCampusdistriapply(campusdistriapply));
    }

    /**
     * 修改分销校区申请列表
     */
    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:edit')")
    @Log(title = "分销校区申请列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Campusdistriapply campusdistriapply)
    {
        return toAjax(campusdistriapplyService.updateCampusdistriapply(campusdistriapply));
    }

    /**
     * 删除分销校区申请列表
     */
    @PreAuthorize("@ss.hasPermi('campus:campusdistriapply:remove')")
    @Log(title = "分销校区申请列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyDistributionIds}")
    public AjaxResult remove(@PathVariable Integer[] applyDistributionIds)
    {
        return toAjax(campusdistriapplyService.deleteCampusdistriapplyByApplyDistributionIds(applyDistributionIds));
    }



    /**
     *  审核分销校区
     */
    @PutMapping("/distribute")
    public AjaxResult distribute(@RequestBody CampusdistriapplyVO campusdistriapplyvo){

        return success(campusdistriapplyService.distribute(campusdistriapplyvo));
    }


}
